package main

import (
	"container/list"
	"fmt"
)

var n, m, x, y int
var mm [][]int
var set = make(map[[2]int]struct{})
var moves = [][2]int{
	{1, 2},
	{1, -2},
	{-1, 2},
	{-1, -2},
	{2, 1},
	{-2, 1},
	{2, -1},
	{-2, -1},
}

func main() {
	fmt.Scanf("%d %d %d %d\n", &n, &m, &x, &y)
	mm = make([][]int, n+1)
	for i := 0; i <= n; i++ {
		mm[i] = make([]int, m+1)
		for j := 1; j <= m; j++ {
			mm[i][j] = -1
		}
	}

	queue := list.New()
	queue.PushBack([][2]int{{x, y}})
	set[[2]int{x, y}] = struct{}{}

	step := 0
	for queue.Len() > 0 {
		pop := queue.Front().Value.([][2]int)
		queue.Remove(queue.Front())
		for _, pos := range pop {
			mm[pos[0]][pos[1]] = step
		}
		nexts := getNextSteps(pop)
		if len(nexts) != 0 {
			queue.PushBack(nexts)
		}
		step++
	}

	for i := 1; i <= n; i++ {
		for j := 1; j <= m-1; j++ {
			fmt.Printf("%-5d", mm[i][j])
		}
		fmt.Println(mm[i][m])
	}
}

func getNextSteps(pop [][2]int) [][2]int {
	ret := make([][2]int, 0)
	for _, pos := range pop {
		for _, move := range moves {
			nx := pos[0] + move[0]
			ny := pos[1] + move[1]
			if nx > n || ny > m || nx < 1 || ny < 1 {
				continue
			}
			if _, ok := set[[2]int{nx, ny}]; ok { // 已经探索过了
				continue
			}

			set[[2]int{nx, ny}] = struct{}{}
			ret = append(ret, [2]int{nx, ny})
		}
	}
	return ret
}
